package com.hongyi.controller;

import com.hongyi.common.Result;
import com.hongyi.service.OrderService;
import com.hongyi.service.UserService;
import com.hongyi.vo.OrderVo;
import com.hongyi.vo.UserVo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hongyi
 * @date 2023/11/22 21:16
 */
@RestController
@RequestMapping("/user")
@MapperScan("com.hongyi.mapper")
public class UserController {
    @Autowired
    private UserService userService;
       @GetMapping("/{id}")
    public Result<UserVo> getById(@PathVariable Long id){
           UserVo userVo = userService.userByIdWithOrders(id);
           return Result.success(userVo);
    }

    @GetMapping("/userList")
    public Result<List<UserVo>> UserOrderList(){
        List<UserVo> userVolist = userService.userListOrder();
        return Result.success(userVolist);
    }

}
// 127.0.0.0.1:9090/user/user/{id}
